{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/javascript": [
       "IPython.notebook.set_autosave_interval(60000)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Autosaving every 60 seconds\n"
     ]
    }
   ],
   "source": [
    "%autosave 60\n",
    "from dir_objectName import dir_objectName,dir_classification, class_, method_, constant_\n",
    "from print_color import print_color\n",
    "import os, sys, re, shutil\n",
    "from glob import glob\n",
    "import multiprocessing\n",
    "import subprocess\n",
    "import os.path\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('CreateHPMImage', '.zip')"
      ]
     },
     "execution_count": 127,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.path.splitext(glob(\"*\")[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      ">>> \u001b[33m         classes         \u001b[0m\n",
      "\n",
      "\n",
      "\n",
      ">>> \u001b[34m  methods or attributes  \u001b[0m\n",
      "\n",
      "\u001b[41m15@\u001b[0mabspath                       \u001b[41m16@\u001b[0maltsep                        \n",
      "\u001b[41m17@\u001b[0mbasename                      \u001b[41m18@\u001b[0mcommonpath                    \u001b[41m19@\u001b[0mcommonprefix                  \u001b[41m20@\u001b[0mcurdir                        \n",
      "\u001b[41m21@\u001b[0mdefpath                       \u001b[41m22@\u001b[0mdevnull                       \u001b[41m23@\u001b[0mdirname                       \u001b[41m24@\u001b[0mexists                        \n",
      "\u001b[41m25@\u001b[0mexpanduser                    \u001b[41m26@\u001b[0mexpandvars                    \u001b[41m27@\u001b[0mextsep                        \u001b[41m28@\u001b[0mgenericpath                   \n",
      "\u001b[41m29@\u001b[0mgetatime                      \u001b[41m30@\u001b[0mgetctime                      \u001b[41m31@\u001b[0mgetmtime                      \u001b[41m32@\u001b[0mgetsize                       \n",
      "\u001b[41m33@\u001b[0misabs                         \u001b[41m34@\u001b[0misdir                         \u001b[41m35@\u001b[0misfile                        \u001b[41m36@\u001b[0mislink                        \n",
      "\u001b[41m37@\u001b[0mismount                       \u001b[41m38@\u001b[0mjoin                          \u001b[41m39@\u001b[0mlexists                       \u001b[41m40@\u001b[0mnormcase                      \n",
      "\u001b[41m41@\u001b[0mnormpath                      \u001b[41m42@\u001b[0mos                            \u001b[41m43@\u001b[0mpardir                        \u001b[41m44@\u001b[0mpathsep                       \n",
      "\u001b[41m45@\u001b[0mrealpath                      \u001b[41m46@\u001b[0mrelpath                       \u001b[41m47@\u001b[0msamefile                      \u001b[41m48@\u001b[0msameopenfile                  \n",
      "\u001b[41m49@\u001b[0msamestat                      \u001b[41m50@\u001b[0msep                           \u001b[41m51@\u001b[0msplit                         \u001b[41m52@\u001b[0msplitdrive                    \n",
      "\u001b[41m53@\u001b[0msplitext                      \u001b[41m54@\u001b[0mstat                          \u001b[41m55@\u001b[0msupports_unicode_filenames    \u001b[41m56@\u001b[0msys                           \n",
      "\n",
      "\n",
      ">>> \u001b[35m        constants        \u001b[0m\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "dir_classification(os.path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['.ipynb_checkpoints',\n",
       " 'CreateHPMImage.zip',\n",
       " 'Modified_SampleConf',\n",
       " 'ningde_rom.hpm',\n",
       " 'ningde_rom.ima',\n",
       " 'SampleConf',\n",
       " 'starlake_bmc_v1_23_06.hpm',\n",
       " 'starlake_bmc_v1_23_06.zip',\n",
       " 'Untitled.ipynb',\n",
       " '修改.txt']"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.listdir()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "list index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-3-4e1ebb11336b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mconf_file\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mglob\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"./*conf_new\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[0mconf_file\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mconf_file\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[0mconf_file\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mIndexError\u001b[0m: list index out of range"
     ]
    }
   ],
   "source": [
    "conf_file = glob(\"./*conf_new\")[0]\n",
    "conf_file = conf_file\n",
    "conf_file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'F:\\\\svn\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage\\\\CreateHPMImage.exe'"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "CreateHPMImage_exe = os.path.abspath(\"CreateHPMImage.exe\")\n",
    "CreateHPMImage_exe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# repl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'conf_file' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-2-cc058da9e857>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mconf_file\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"r\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m     \u001b[0mcontent\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreadlines\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'conf_file' is not defined"
     ]
    }
   ],
   "source": [
    "with open(conf_file, \"r\") as f:\n",
    "    content = f.readlines()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [],
   "source": [
    "p = re.compile(r'^\\s+(?:HPMImage|PrivateKey|FwData)')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [],
   "source": [
    "def repl(matchobj):\n",
    "#     print(matchobj.group(), type(matchobj.group()))\n",
    "    file_name = re.split(r\"/|//|\\\\|\\\\\\\\\", matchobj.group())[-1]\n",
    "    print(file_name)\n",
    "#     abs_path = os.path.abspath(file_name)\n",
    "    result = \" \" + os.path.abspath(file_name)\n",
    "    print(result)\n",
    "    return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ningde_rom.hpm\n",
      " F:\\svn\\Glutton_formal\\app\\tool\\CreateHPMImage\\ningde_rom.hpm\n",
      "    HPMImage            = F:\\svn\\Glutton_formal\\app\\tool\\CreateHPMImage\\ningde_rom.hpm          ; Path & Filename of final output HPM Image\n",
      "\n",
      "private.pem\n",
      " F:\\svn\\Glutton_formal\\app\\tool\\CreateHPMImage\\private.pem\n",
      "    PrivateKey          = F:\\svn\\Glutton_formal\\app\\tool\\CreateHPMImage\\private.pem                 ; path to private key\n",
      "\n",
      "ningde_rom.ima\n",
      " F:\\svn\\Glutton_formal\\app\\tool\\CreateHPMImage\\ningde_rom.ima\n",
      "    FwData              = F:\\svn\\Glutton_formal\\app\\tool\\CreateHPMImage\\ningde_rom.ima                     ; Path & Filename of \"Boot\" Component's Image. (In our case it is rom.ima)\n",
      "\n",
      "ningde_rom.ima\n",
      " F:\\svn\\Glutton_formal\\app\\tool\\CreateHPMImage\\ningde_rom.ima\n",
      "    FwData              = F:\\svn\\Glutton_formal\\app\\tool\\CreateHPMImage\\ningde_rom.ima  \t\t            ; Path & Filename of \"App\" Component's Image. (In our case it is rom.ima)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for i, e in enumerate(content):\n",
    "    finded = re.search(p, e)\n",
    "    if finded :\n",
    "#         print(elem)\n",
    "        content[i] = re.sub(\"(?<==)\\s+[^\\s]+\", repl, e)\n",
    "        print(content[i])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"ningde_bmc.conf_new\", \"w\") as f:\n",
    "    for line in content:\n",
    "        f.write(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [],
   "source": [
    "def repl(match_obj):\n",
    "    print(\"match_obj.group()[0]: \", match_obj.group()[0])\n",
    "    if \"FwData\" in match_obj.group()[0]:\n",
    "        return FwData_path\n",
    "    elif \"HPMImage\" in match_obj.group()[0]:\n",
    "        return HPMImage_path\n",
    "\n",
    "def modify_conf(conf_file):\n",
    "    FwData_file_name = glob(\"*.ima\")[0]\n",
    "    FwData_path = os.path.abspath(FwData_file_name)\n",
    "    HPMImage_file_name =  os.path.splitext(FwData_file_name)[0] + \".hpm\"\n",
    "    HPMImage_path = os.path.join(os.path.dirname(FwData_path), HPMImage_file_name)\n",
    "    # modify HPMImage|FwData|PrivateKey's value that is unsuitable path in *conf file in the current environment\n",
    "    with open(conf_file, \"r\") as f:\n",
    "        content = f.readlines()\n",
    "    FwData_p = re.compile(r'^\\s+FwData\\s+=')\n",
    "    HPMImage_p = re.compile(r'^\\s+HPMImage\\s+=')\n",
    "    for i, e in enumerate(content):\n",
    "        if re.search(FwData_p, e):\n",
    "            content[i] = re.sub(r\"(?<==)\\s+[^\\s]+\", repl, e)\n",
    "            continue\n",
    "        if re.search(HPMImage_p, e):\n",
    "            content[i] = re.sub(r\"(?<==)\\s+[^\\s]+\", repl, e)\n",
    "            continue\n",
    "    # save conf_file_modified under createhpmimage_data_path\n",
    "    conf_file_modified = os.path.basename(conf_file)\n",
    "    with open(conf_file_modified, \"w\") as f:\n",
    "        for line in content:\n",
    "            f.write(line)\n",
    "    return conf_file_modified"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'F:\\\\svn\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage\\\\ningde_rom.ima'"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "FwData_file_name = glob(\"*.ima\")[0]\n",
    "FwData_path = os.path.abspath(FwData_file_name)\n",
    "FwData_path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'F:\\\\svn\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage\\\\ningde_rom.hpm'"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "HPMImage_file_name =  os.path.splitext(FwData_file_name)[0] + \".hpm\"\n",
    "HPMImage_path = os.path.join(os.path.dirname(FwData_path), HPMImage_file_name)\n",
    "HPMImage_path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [],
   "source": [
    "conf_file = \"F:\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage\\\\SampleConf\\\\ningde_bmc.conf\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "match_obj.group()[0]:   \n",
      "match_obj.group()[0]:   \n",
      "match_obj.group()[0]:   \n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'ningde_bmc.conf'"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "modify_conf(conf_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'**abc **'"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = \"123abc 1456\"\n",
    "re.sub(r\"\\d+\", lambda match_obj: \"**\", s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "os.path.splitext()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Glutton_formal'"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.path.basename('E:\\\\Glutton_formal')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'f:\\\\Glutton_formal\\x07pp\\tool\\\\CreateHPMImage\\\\starlake_bmc_v1_23_06\\\\.ima'"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.path.normpath(\"f:\\Glutton_formal\\app\\tool\\CreateHPMImage\\starlake_bmc_v1_23_06/.ima\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CreateHPMImage_exe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(b'Erase Block size is 10000 \\n +--------------------------------------------+\\n| MegaRAC SPX Create HPM Image Tool v1.0     |\\n| Copyright (c) 2019 American Megatrends Inc.|\\n+--------------------------------------------+\\n\\nHPM Upgrade Image: F:\\\\svn\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage\\\\ningde_rom.hpm has been created sucessfully.\\n',\n",
       " '')"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "try:\n",
    "    completed = subprocess.Popen(\n",
    "        [CreateHPMImage_exe, 'create', conf_file],\n",
    "        stdout=subprocess.PIPE, \n",
    "        stderr=subprocess.PIPE,\n",
    "        shell=True\n",
    "    )\n",
    "except Exception as e:\n",
    "    print(\"CalledProcessError: \" + str(e))\n",
    "\n",
    "stdout, stderr = completed.communicate()\n",
    "stdout, stderr.decode(\"gbk\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [],
   "source": [
    "CreateHPMImage_exe =\"F:\\\\svn\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage.exe\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [],
   "source": [
    "conf_file =\"F:\\\\svn\\\\Glutton_formal\\\\app\\\\tool\\\\ningde_bmc.conf_new\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"test.txt\", \"w\") as f:\n",
    "    f.write(stdout.decode(\"gbk\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stderr.decode(\"gbk\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# SampleConf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"172.22.27.146:8060\"：\"E:\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage\\\\private.pem\"\n",
    "\n",
    "\"172.22.27.146\": \"C:\\\\Users\\\\fiona\\\\Desktop\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage\\\\private.pem\"\n",
    "\n",
    "\"127.0.0.1:5000\": \"F:\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage\\\\private.pem\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {},
   "outputs": [],
   "source": [
    "def repl(matchobj):\n",
    "#     print(matchobj.group(), type(matchobj.group()))\n",
    "    file_name = re.split(r\"[/|//|\\\\|\\\\\\\\]\", matchobj.group())[-1]\n",
    "#     print(file_name)\n",
    "#     abs_path = os.path.abspath(file_name)\n",
    "#     private_pem_file = \"C:\\\\Users\\\\fiona\\\\Desktop\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage\\\\private.pem\"\n",
    "    private_pem_file = \"C:\\\\Users\\\\fiona\\\\Desktop\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage\\\\private.pem\"\n",
    "    result = \" \" + private_pem_file\n",
    "#     print(result)\n",
    "    return result\n",
    "\n",
    "p = re.compile(r'^\\s+(?:PrivateKey)')\n",
    "for conf in os.listdir(\"SampleConf\"):\n",
    "    SampleConf_conf = os.path.join(\"SampleConf\",conf)\n",
    "    with open(SampleConf_conf, \"r\") as f:\n",
    "        content = f.readlines()\n",
    "    for i, e in enumerate(content):\n",
    "        finded = re.search(p, e)\n",
    "        if finded :\n",
    "    #         print(elem)\n",
    "            content[i] = re.sub(\"(?<==)\\s+[^\\s]+\", repl, e)\n",
    "#             print(content[i])\n",
    "    Modified_conf = os.path.join(\"Modified_SampleConf\", conf)\n",
    "    with open(Modified_conf, \"w\") as f:\n",
    "        for line in content:\n",
    "            f.write(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'CreateHPMImage.exe'"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.path.basename(CreateHPMImage_exe)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# select_conf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<option value=\"bios_image.conf\">bios_image.conf</option>\n",
      "<option value=\"cpld_image.conf\">cpld_image.conf</option>\n",
      "<option value=\"f4_hpm_V01_0.conf\">f4_hpm_V01_0.conf</option>\n",
      "<option value=\"f8_hpm_V01_1.conf\">f8_hpm_V01_1.conf</option>\n",
      "<option value=\"gt_disp_hpm_V01_0.conf\">gt_disp_hpm_V01_0.conf</option>\n",
      "<option value=\"gt_fan_hpm_V01_0.conf\">gt_fan_hpm_V01_0.conf</option>\n",
      "<option value=\"gt_r4_hpm_V01_0.conf\">gt_r4_hpm_V01_0.conf</option>\n",
      "<option value=\"ningde_bmc.conf\">ningde_bmc.conf</option>\n",
      "<option value=\"r4_hpm_V01_0.conf\">r4_hpm_V01_0.conf</option>\n"
     ]
    }
   ],
   "source": [
    "for conf in os.listdir(\"SampleConf\"):\n",
    "    print(f'<option value=\"{conf}\">{conf}</option>')"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "<option value=\"pcie\">Pcie</option>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['.ipynb_checkpoints',\n",
       " 'CreateHPMImage.exe',\n",
       " 'CreateHPMImage.zip',\n",
       " 'cygcrypto-1.1.dll',\n",
       " 'cygwin1.dll',\n",
       " 'cygz.dll',\n",
       " 'Modified_SampleConf',\n",
       " 'ningde_bmc.conf',\n",
       " 'ningde_rom.hpm',\n",
       " 'ningde_rom.ima',\n",
       " 'private.pem',\n",
       " 'SampleConf',\n",
       " 'starlake_bmc_v1_23_06.hpm',\n",
       " 'starlake_bmc_v1_23_06.ima',\n",
       " 'starlake_bmc_v1_23_06.zip',\n",
       " 'test.py',\n",
       " 'Untitled.ipynb',\n",
       " '修改.txt']"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.listdir()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'F:\\\\svn\\\\Glutton_formal\\\\app\\\\tool\\\\CreateHPMImage'"
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'test.py'"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "glob(\"test.py\")[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [],
   "source": [
    "shutil.rmtree(\"新建文件夹\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 3]"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(filter(lambda x: isinstance(x, int), [1, \"0\", 3]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
